How to write the polynomial given the factors